<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body>
<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
    <form class="layui-form serch" action="{:url('admin/member/index')}" method="post">
        <div class="layui-form-item" style="float: left;">
            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="title" value="{:input('request.name/s','')}" autocomplete="off" placeholder="请输入成员名称" class="layui-input layui-btn-sm">
            </div>
            <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>
            <a class="layui-btn layui-btn-danger layui-btn-sm" href="{:url('member/index')}">清空</a>
            <a href="{:url('member/add')}" class="layui-btn layui-btn-sm a_menu">
                添加成员
            </a>
        </div>
    </form>
</fieldset>
<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm" >
    <thead>
    <tr>
        <th>编号</th>
        <th>成员名称</th>
        <th>性别</th>
        <th>图片</th>
        <th>手机号</th>
        <th>城乡</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="member" id="vo"}
    <tr>
        <td>{$key+1}</td>
        <td>{$vo.name}</td>
        <td>{if condition="$vo.sex==0"}男
            {else /}女
            {/if}
        </td>
        <td><a href="{$vo.thumb|geturl}" class="tooltip">
            <img src="{$vo.thumb|geturl}" width="20" height="20"></a></td>
        <td>{$vo.phone}</td>
        <td>{$vo.city}</td>
        <td class="operation-menu">
            <a href="{:url('admin/member/add',['id'=>$vo.id])}" class="a_menu"><button class="layui-btn layui-btn-xs" ><i class="layui-icon"></i></button></a>
            <button class="layui-btn layui-btn-xs delete" id="{$vo.id}"><i class="layui-icon"></i></button>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
<div style="padding:0 20px;">{$member->render()}</div>

<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
    var message;
    layui.config({
        base: '__JS__/',
        version: '1.0.1'
    }).use(['app', 'message'], function() {
        var app = layui.app,
            $ = layui.jquery,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();
    });
</script>
<script type="text/javascript">

    $('.delete').click(function(){
        var id = $(this).attr('id');
        layer.confirm('确定要删除?', function(index) {
            $.ajax({
                url:"{:url('admin/member/delete')}",
                data:{id:id},
                success:function(res) {
                    layer.msg(res.msg);
                    if(res.code == 1) {
                        setTimeout(function(){
                            location.href = res.url;
                        },1500)
                    }
                }
            })
        })
    })
</script>
<script type="text/javascript">
    $('.a_menu').click(function(){
        var url = $(this).attr('href');
        var id = $(this).attr('id');
        var a = true;
        if(id) {
            $.ajax({
                url:url
                ,async:false
                ,data:{id:id}
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = false;
                    }
                }
            })
        } else {
            $.ajax({
                url:url
                ,async:false
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = false;
                    }
                }
            })
        }
        return a;
    })
</script>
</body>
</html>
